<?
if($_GET['page'] == 'account')
{
	$uid = $_SESSION['uid']; 
	$query = "select * from tbl_reporting_personnel where rp_id= $uid";
	$result = mysql_query($query);
	if (mysql_num_rows($result)!= 1) {$error = 1;} 
	else { 
		$row = mysql_fetch_row($result);
		$rp_first_name = $_POST['rp_first_name'];
		$rp_last_name = $_POST['rp_last_name'];
		$rp_phone_number = $_POST['rp_phone_number'];
		$rp_phone_ext = $_POST['rp_phone_ext'];
		$rp_fax_number = $_POST['rp_fax_number'];
		$rp_email = $_POST['rp_email'];
		$rp_user_name = $_POST['rp_user_name'];
		$password = $_POST['rp_password'];
		$rp_password = md5($password);
		if($_POST['submit']=='submit')
		{
			$update_query = "UPDATE tbl_reporting_personnel SET rp_first_name='$rp_first_name',rp_last_name='$rp_last_name',rp_phone_number='$rp_phone_number'," .
					"rp_phone_ext='$rp_phone_ext',rp_fax_number='$rp_fax_number',rp_email='$rp_email',rp_password='$rp_password' WHERE rp_id = '".$uid."' LIMIT 1;";
			$update_result = mysql_query($update_query);                  
		    if (!$update_result) {die('Query error: '. mysql_error());}
		    else {
		    	$query = "select * from tbl_reporting_personnel where rp_id= $uid";
				$result = mysql_query($query);
			 	$row = mysql_fetch_row($result);
		    }
		}
	}
}
?>
<form action="index.php?page=account" method="post">
<fieldset style="margin:10px;padding:10px;">
<legend><strong>Reporting Personnel Account Information</strong></legend>
<table cellpadding="4">
	<tr>
		<td><label><strong>First Name :</strong></label></td>
		<td><input type="text" name="rp_first_name" value="<? echo $row[2];?>" /></td>
	</tr>
	<tr>
		<td><label><strong>Last Name :</strong></label></td>
		<td><input type="text" name="rp_last_name" value="<? echo $row[3];?>"/></td>
	</tr>
	<tr>
		<td><label><strong>Company Name :</strong></label></td>
		<td><select name="c_nickname">
									<option value="value1">company1</option>
									<option value="value2">company2</option>
									<option value="value3">company3</option>
									<option value="value3">company4</option>
								</select></td>
	</tr>
	<tr>
		<td><label><strong>Phone Number :</strong></label></td>
		<td><input type="text" name="rp_phone_number" value="<? echo $row[4];?>"/></td>
	</tr>
	<tr>
		<td><label><strong>Extension :</strong></label></td>
		<td><input type="text" name="rp_phone_ext" value="<? echo $row[5];?>"/></td>
	</tr>
	<tr>
		<td><label><strong>Fax Number :</strong></label></td>
		<td><input type="text" name="rp_fax_number" value="<? echo $row[6];?>"/></td>
	</tr>
	<tr>
		<td><label><strong>Email :</strong></label></td>
		<td><input type="text" name="rp_email" value="<? echo $row[7];?>"/></td>
	</tr>
	<tr>
		<td><label><strong>Username :</strong></label></td>
		<td><input type="text" name="rp_user_name" value="<? echo $row[8];?>" readonly/></td>
	</tr>
	<tr>
		<td><label><strong>Password :</strong></label></td>
		<td><input type="password" name="rp_password" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" value="submit" name="submit" /></td>
	</tr>
</table>
</fieldset>
</form>
